#include <bits/stdc++.h>
using namespace std;
int blank[3000][3000];
int main() {
  int n;
  cin >> n;
  // 将数组blank初始化为-1
  memset(blank, -1, sizeof(blank));

  for (int i = 1; i <= n; i++) {
    int a, b, g, k;
    cin >> a >> b >> g >> k;
    for (int H = a; H <= a + g; H++) {
      for (int L = b; L <= b + k; L++) {
        blank[H][L] = i;
      }
    }
  }
  int x, y;
  cin >> x >> y;
  cout << blank[x][y];
  return 0;
}